<?php

use yii\db\Migration;

/**
 * Class m190919_020919_posts
 */
class m190919_020919_posts extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="发帖表"';
        $this->createTable('{{%posts}}', [
            'id' => $this->primaryKey(),
            'title' => $this->string()->notNull()->comment('标题'),
            'describe' => $this->text()->comment('简介'),
            'img' => $this->string()->comment('多图'),
            'admin_id' => $this->integer()->comment('管理员id'),
            'admin_name' => $this->string()->comment('管理员名称'),
            'set_posts_id' => $this->integer()->comment('发帖人id'),
            'set_posts_name' => $this->string()->comment('发帖人名称'),
            'comment_num' => $this->integer()->defaultValue(0)->comment('评论数'),
            'status' => $this->smallInteger()->notNull()->defaultValue(1)->comment('状态 1待审核2拒绝3通过'),
            'type' => $this->smallInteger()->comment('帖子类型 1为影视学堂，2为群组'),
            'error' => $this->string()->comment('拒绝理由'),
            'created_at' => $this->integer()->notNull(),
            'updated_at' => $this->integer(),
            'deleted_at' => $this->integer(),
        ],$tableOptions);
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('{{%posts}}');
        return false;
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m190919_020919_posts cannot be reverted.\n";

        return false;
    }
    */
}
